<template>
    <header>
        <div class="header-wraper">
            <div class="header-top">
                <img :src="seller.avatar" alt="" class="avatar"/>
                <div class="seller-msg">
                    <h2 class="seller-title"><span class="title-icon"></span><span
                            class="title-content">{{seller.name}}</span></h2>
                    <p class="seller-detail">{{seller.description}}&nbsp;/&nbsp;{{seller.deliveryTime}}分钟送达</p>
                    <p class="seller-purchase" v-if="seller.supports">
                        <v-purchase :size="1" :icon="classMap[seller.supports[0].type]"></v-purchase>
                        <span class="purchase-text">{{seller.supports[0].description}}</span>
                    </p>
                </div>
                <div class="more" @click="changeDetail">
                    <span class="num">5个</span>
                    <i class="icon icon-keyboard_arrow_right"></i>
                </div>
            </div>
            <div class="header-announce">
                <span class="announce-icon"></span>
                <span class="announce-content">{{seller.bulletin}}</span>
                <i class="icon icon-keyboard_arrow_right"></i>
            </div>
            <div class="background-pannel">
                <img :src="seller.avatar" width="100%" height="100%"/>
            </div>
        </div>
        <transition name="fade">
            <div class="detail-pannel" v-show="showDetail" >
                <div class="detail-wraper clearfix">
                    <div class="detail-main">
                        <h2 class="seller-name">{{seller.name}}</h2>
                        <div class="star-container">
                            <v-star :size="48" :score="seller.score"></v-star>
                        </div>
                        <div class="detail-title">
                            <div class="line"></div>
                            <div class="title-content">优惠信息</div>
                            <div class="line"></div>
                        </div>
                        <ul class="detail-list" v-if="seller.supports">
                            <li v-for="(item,index) in seller.supports" class="detail-list-item">
                                <v-purchase :size="1" :icon="classMap[seller.supports[index].type]"></v-purchase>
                                <span class="support-text">{{seller.supports[index].description}}</span>
                            </li>
                        </ul>
                        <div class="detail-title">
                            <div class="line"></div>
                            <div class="title-content">商家公告</div>
                            <div class="line"></div>
                        </div>
                        <div class="section">{{seller.bulletin}}</div>
                    </div>
                </div>
                <div class="detail-close">
                    <i class="icon-close" @click="changeDetail"></i>
                </div>
            </div>
        </transition>
    </header>
</template>
<script type="es6">
    import star from '../star/star'
    import purchase from '../purchase/purchase'
    export default {
        props: {
            seller: {
                type: Object
            }
        },
        data(){
            return {
                classMap: [],
                showDetail: false
            }
        },
        methods: {
            changeDetail (){
                this.showDetail = !this.showDetail
            }
        },
        //组件初始化时调用的方法
        created(){
            this.classMap = ['decrease', 'discount', 'special', 'invoice', 'guarantee']
        },
        components: {
            'v-star': star,
            'v-purchase':purchase
        }
    }
</script>
<style lang="less" rel="stylesheet/less">
    @import '../../../public/stylesheet/mixin.less';

    .fade-enter-active,.fade-leave-active{
        transition:opacity 0.5s;
    }
    .fade-enter,.fade-leave-active{
        opacity:0;
    }

    .header-wraper {
        position: relative;
        overflow: hidden;
        background: rgba(7, 17, 27, 0.5);
        .header-top {
            position: relative;
            padding: 24px 0 18px 24px;
            font-size: 0;
            .avatar {
                display: inline-block;
                vertical-align: top;
                width: 64px;
                height: 64px;
                border-radius: 4px;
            }
            .seller-msg {
                display: inline-block;
                margin-left: 16px;
                .seller-title {
                    height: 18px;
                    display: flex;
                    align-items: center;
                    .title-icon {
                        width: 30px;
                        height: 18px;
                        .bg-img('brand');
                        background-size: 30px 18px;
                        background-repeat: no-repeat
                    }
                    .title-content {
                        margin-left: 6px;
                        margin-top: 1px;
                        font-size: 16px;
                        line-height: 18px;
                        font-weight: bold;
                        color: #fff;
                    }
                }
                .seller-detail {
                    margin-top: 8px;
                    margin-bottom: 10px;
                    font-size: 12px;
                    line-height: 12px;
                    color: rgba(255, 255, 255, 0.6);

                }

                .seller-purchase {
                    display: inline-flex;
                    align-items: center;
                    height: 12px;
                    .purchase-text {
                        font-size: 10px;
                        margin-left: 4px;
                        margin-top: 1px;
                        font-weight: 500;
                        line-height: 1;
                        color: rgba(255, 255, 255, 0.6);

                    }

                }

            }
            .more {
                position: absolute;
                right: 12px;
                bottom: 18px;
                padding: 7px 8px;
                border-radius: 8px;
                background: rgba(0, 0, 0, 0.2);
                font-size: 0;
                .num {
                    display: inline-block;
                    vertical-align: middle;
                    margin-top: 2.3px;
                    margin-right: 2px;
                    font-size: 10px;
                    line-height: 1;
                    color: rgba(255, 255, 255, 0.6);
                    font-weight: 500;

                }
                .icon {
                    display: inline-block;
                    vertical-align: middle;
                    font-size: 10px;
                    color: rgba(255, 255, 255, 0.6);
                }

            }

        }
        .header-announce {
            position: relative;
            box-sizing: border-box;
            height: 28px;
            line-height: 25.5px;
            padding: 2.5px 22px 0 12px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
            color: #fff;
            background: rgba(7, 17, 27, 0.2);
            .announce-icon {
                vertical-align: middle;
                display: inline-block;
                line-height: 1;
                width: 22px;
                height: 12px;
                margin-top: -2.5px;
                background-size: 22px 12px;
                background-repeat: no-repeat;
                .bg-img("bulletin");

            }
            .announce-content {
                vertical-align: middle;
                margin: 0 4px;
                font-size: 10px;
                font-weight: 200;
                color: rgba(255, 255, 255, 0.6);
            }

            .icon {
                position: absolute;
                right: 12px;
                top: 50%;
                margin-top: -5px;
                font-size: 10px;
                color: #fff;
            }
        }
        .background-pannel {
            position: absolute;
            box-sizing: border-box;
            z-index: -1;
            width: 100%;
            height: 100%;
            padding-top: 35px;
            top: 0;
            left: 0;
            filter: blur(10px);
        }

    }

    .detail-pannel {
        position: fixed;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        background: rgba(7, 17, 27, 0.8);
        //只有在iphone下有效
        backdrop-filter: blur(10px);
        overflow: auto;
        z-index: 1002;
        .detail-wraper {
            min-height: 100%;
            width: 100%;
            .detail-main {
                margin-top: 40px;
                padding-bottom: 64px;
                .seller-name {
                    text-align: center;
                    font-size: 16px;
                    font-weight: 700;
                    line-height: 16px;
                    margin-bottom: 11px;
                    color: rgb(255, 255, 255);
                }
                .star-container {
                    text-align: center;

                }
                .detail-title {
                    display: flex;
                    width: 80%;
                    margin: 28px auto 24px auto;
                    font-size: 0;
                    align-items: center;
                    .line {
                        display: flex;
                        flex: 1;
                        height: 1px;
                        margin-top: -4px;
                        background: rgba(255, 255, 255, 0.2);
                    }
                    .title-content {
                        font-size: 14px;
                        font-weight: 700;
                        padding: 0 12px;
                        color: rgb(255, 255, 255);
                    }

                }
                .detail-list {
                    width: 80%;
                    margin:0 auto;
                    .detail-list-item {
                        font-size:0;
                        &:not(:last-child){
                            margin-bottom:10px;
                        }
                        .support-text {
                            font-size: 12px;
                            line-height: 14px;
                            margin-left:6px;
                            font-weight: 200;
                            color: #fff;
                        }
                    }

                }
                .section{
                    box-sizing:border-box;
                    width:80%;
                    margin:0 auto;
                    padding:0 12px;
                    font-size:12px;
                    line-height:24px;
                    font-weight:200;
                    color:#fff;
                }
            }
        }
        .detail-close {
            position: relative;
            width: 32px;
            height: 32px;
            font-size: 32px;
            margin: -64px auto 0;
            clear: both;
        }
    }


</style>
